#ifndef _XBASE_ROOT_META_MANAGER_
#define _XBASE_ROOT_META_MANAGER_

#include <boost/thread/mutex.hpp>

#include <protocol_struct.hpp>

namespace xbase
{
	class root_meta_manager
	{
	public:
		root_meta_manager()
			: m_valid(false)
			{}

		void update(const protocol::server_address &p_addr) {
			boost::mutex::scoped_lock lock(m_mutex);
			m_address = p_addr;
			m_valid = true;
		}

		protocol::server_address get() const {
			boost::mutex::scoped_lock lock(m_mutex);
			return m_address;
		}

		bool valid() const {
			boost::mutex::scoped_lock lock(m_mutex);
			return m_valid;
		}

		void set_invalid() {
			boost::mutex::scoped_lock lock(m_mutex);
			m_valid = false;
		}
	private:
		bool m_valid;
		protocol::server_address m_address;
		mutable boost::mutex m_mutex;
	};
} // namespace xbase

#endif	// _XBASE_ROOT_META_MANAGER_

